home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Hardware / PowerManager DDK 1.0f1 / Interfaces&Libraries / Interfaces / UTCUtils.h < prev   
Encoding:
C/C++ Source or Header  |  1999-10-08  |  3.0 KB  |  140 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        UTCUtils.h
  3.  
  4.      Contains:    Interface for UTC to Local Time conversion and 64 Bit Clock routines
  5.  
  6.      Version:    Sonata
  7.  
  8.      DRI:        Julio Gonzalez
  9.  
  10.      Copyright:    © 1999 by Apple Computer, Inc., all rights reserved.
  11.  
  12.      Warning:    *** APPLE INTERNAL USE ONLY ***
  13.                  This file may contain unreleased API's
  14.  
  15.      BuildInfo:    Built by:            Scott Johnson
  16.                  On:                    10/8/99 11:27 AM
  17.                  With Interfacer:    3.0d13   (MPW PowerPC)
  18.                  From:                UTCUtils.i
  19.                      Revision:        3
  20.                      Dated:            4/14/99
  21.                      Last change by:    jag
  22.                      Last comment:    Rename some of the new APIs to be more consistent with old 32
  23.  
  24.      Bugs:        Report bugs to Radar component "System Interfaces", "Latest"
  25.                  List the version information (from above) in the Problem Description.
  26.  
  27. */
  28. #ifndef __UTCUTILS__
  29. #define __UTCUTILS__
  30.  
  31. #ifndef __MACTYPES__
  32. #include <MacTypes.h>
  33. #endif
  34.  
  35.  
  36.  
  37.  
  38. #if PRAGMA_ONCE
  39. #pragma once
  40. #endif
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. #if PRAGMA_IMPORT
  47. #pragma import on
  48. #endif
  49.  
  50. #if PRAGMA_STRUCT_ALIGN
  51.     #pragma options align=mac68k
  52. #elif PRAGMA_STRUCT_PACKPUSH
  53.     #pragma pack(push, 2)
  54. #elif PRAGMA_STRUCT_PACK
  55.     #pragma pack(2)
  56. #endif
  57.  
  58. /* Status Codes */
  59. enum {
  60.     kUTCUnderflowErr            = -8850,
  61.     kUTCOverflowErr                = -8851,
  62.     kIllegalClockValueErr        = -8852
  63. };
  64.  
  65.  
  66.  
  67. /* 64 Bit Clock Typedefs */
  68.  
  69. struct UTCDateTime {
  70.     UInt16                             highSeconds;
  71.     UInt32                             lowSeconds;
  72.     UInt16                             fraction;
  73. };
  74. typedef struct UTCDateTime                UTCDateTime;
  75. typedef UTCDateTime *                    UTCDateTimePtr;
  76. typedef UTCDateTimePtr *                UTCDateTimeHandle;
  77.  
  78. struct LocalDateTime {
  79.     UInt16                             highSeconds;
  80.     UInt32                             lowSeconds;
  81.     UInt16                             fraction;
  82. };
  83. typedef struct LocalDateTime            LocalDateTime;
  84. typedef LocalDateTime *                    LocalDateTimePtr;
  85. typedef LocalDateTimePtr *                LocalDateTimeHandle;
  86. /* Classic 32 bit clock conversion routines */
  87. EXTERN_API_C( OSStatus )
  88. ConvertLocalTimeToUTC            (UInt32                 localSeconds,
  89.                                  UInt32 *                utcSeconds);
  90.  
  91. EXTERN_API_C( OSStatus )
  92. ConvertUTCToLocalTime            (UInt32                 utcSeconds,
  93.                                  UInt32 *                localSeconds);
  94.  
  95. /* 64 bit clock conversion routines */
  96. EXTERN_API_C( OSStatus )
  97. ConvertUTCToLocalDateTime        (const UTCDateTime *    utcDateTime,
  98.                                  LocalDateTime *        localDateTime);
  99.  
  100. EXTERN_API_C( OSStatus )
  101. ConvertLocalToUTCDateTime        (const LocalDateTime *    localDateTime,
  102.                                  UTCDateTime *            utcDateTime);
  103.  
  104. /* Getter and Setter Clock routines using 64 Bit values */
  105. EXTERN_API_C( OSStatus )
  106. GetUTCDateTime                    (UTCDateTime *            utcDateTime,
  107.                                  Boolean                 needFraction);
  108.  
  109. EXTERN_API_C( OSStatus )
  110. SetUTCDateTime                    (const UTCDateTime *    utcDateTime);
  111.  
  112. EXTERN_API_C( OSStatus )
  113. GetLocalDateTime                (LocalDateTime *        localDateTime,
  114.                                  Boolean                 needFraction);
  115.  
  116. EXTERN_API_C( OSStatus )
  117. SetLocalDateTime                (const LocalDateTime *    localDateTime);
  118.  
  119.  
  120. #if PRAGMA_STRUCT_ALIGN
  121.     #pragma options align=reset
  122. #elif PRAGMA_STRUCT_PACKPUSH
  123.     #pragma pack(pop)
  124. #elif PRAGMA_STRUCT_PACK
  125.     #pragma pack()
  126. #endif
  127.  
  128. #ifdef PRAGMA_IMPORT_OFF
  129. #pragma import off
  130. #elif PRAGMA_IMPORT
  131. #pragma import reset
  132. #endif
  133.  
  134. #ifdef __cplusplus
  135. }
  136. #endif
  137.  
  138. #endif /* __UTCUTILS__ */
  139.  
  140.